#ifndef SEARCH_SEARCHALGORITHM_H_INCLUDED
#define SEARCH_SEARCHALGORITHM_H_INCLUDED

#include <Core/SearchEngine/ISearchEngine.h>

#include <vector>
#include <string>

namespace Core {

class SearchEngine : public ISearchEngine
{
public :
	SearchEngine();
	~SearchEngine();
	
	virtual std::string searchStart(
		Common::IInputDevicePtr const inputDeviceImpl, IKeyValueStoragePtr const keyValueStorageImpl);

private :
	static std::size_t const BUF_SIZE = 1000;
	std::string buffer;
	std::size_t m_keyMaxLength;

	void scanArray(Common::IInputDevicePtr const searchTraits);
	
	void findSignature(
		Common::IInputDevicePtr const searchTraits, 
		IKeyValueStoragePtr const keyValueStorageImpl, 
		std::string & sign);

	void loadArray(Common::IInputDevicePtr  const searchTraits, boost::int64_t from, size_t size);
	
	void runArrayLoading(Common::IInputDevicePtr const searchTraits, boost::int64_t from, size_t bufsize);

};

}

#endif

